package com.wenyu.wenyuyuedu.adapter.homepagefragment;

import android.content.Context;
import android.text.Html;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.wenyu.wenyuyuedu.R;
import com.wenyu.wenyuyuedu.bean.homepager.NewAllAttentionBean;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2017/3/18.
 * 二级评论
 */

public class SecondCommentAdapter extends BaseAdapter {
    private List<NewAllAttentionBean.InfoBean.AllCommentBean.SonCommentBean> son_comment = new ArrayList<>();
    private Context context;
    public int position;

    public SecondCommentAdapter(Context context, int position) {
        this.context = context;
        this.position = position;
    }

    @Override
    public int getCount() {
        return son_comment.size();
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        MyViewHolder holder = null;
        if (view == null) {
            holder = new MyViewHolder();
            view = View.inflate(context, R.layout.second_comment_item, null);
            holder.comment_name = (TextView) view.findViewById(R.id.comment_name);
            view.setTag(holder);
        } else {
            holder = (MyViewHolder) view.getTag();
        }
        String to_comment_name = son_comment.get(i).getTo_comment_name();
        String comment_name = son_comment.get(i).getComment_name();
        String content = son_comment.get(i).getContent();
        holder.comment_name.setText(Html.fromHtml("<b>" + "<font color = '#576b95'>" + comment_name + "</font>" + "</b>"+ "<font color='#333333'>" + "回复" + "</font>" + "<b>" + "<font color = '#576b95'>" + to_comment_name + "</font>" + "</b>" +
                "<font color='#000000'>" + ":" + "</font>" + "<font color='#000000'>" + content + "</font>"));
        System.out.println("SecondCommentAdapter:000 " + son_comment.size());
        return view;
    }

    public void addAll(List<NewAllAttentionBean.InfoBean.AllCommentBean.SonCommentBean> son_comment) {
        if (son_comment != null) {
            this.son_comment = son_comment;
            notifyDataSetChanged();
        }
    }

    class MyViewHolder {
        TextView comment_name;
    }

    public List<NewAllAttentionBean.InfoBean.AllCommentBean.SonCommentBean> getList() {
        System.out.println("SecondCommentAdapter: " + son_comment.size());
        return son_comment;
    }
}
